<template>
  <a-form ref="formRef" :model="form" :rules="rules" layout="vertical">
    <a-row :gutter="20">
      <a-col :span="12">
        <a-form-item name="eqpCode">
          <template #label>
            <span>
              设备id
              <a-tooltip v-if="false">
                <template #title></template>
                <QuestionCircleOutlined/>
              </a-tooltip>
              <span>：</span>
            </span>
          </template>
          <a-input v-model:value="form.eqpCode" :disabled="isUpdate" allow-clear placeholder="请输入设备CODE"/>
        </a-form-item>
      </a-col>
      <a-col :span="12">
        <a-form-item name="orgCode">
          <template #label>
            <span>
              数据机构
              <a-tooltip v-if="false">
                <template #title></template>
                <QuestionCircleOutlined/>
              </a-tooltip>
              <span>：</span>
            </span>
          </template>
          <a-tree-select
            v-model:value="form.orgCode"
            placeholder="请选择"
            :dropdownStyle="{maxHeight:'200px',overflow:'auto'}"
            :treeData="props.orgidlist"
            :replaceFields="{label: 'ORG_NAME', key: 'ORG_ID',value: 'ORG_ID',children:'children' }"
            show-search
          >
          </a-tree-select>
          <!--          <a-input v-model:value="form.orgCodeName" placeholder="请选择所属组织编码（工厂-车间-产线）" @focus="orgCodeClick()"/>-->
        </a-form-item>
      </a-col>
      <a-col :span="12">
        <a-form-item name="eqpname">
          <template #label>
            <span>
              设备名称
              <a-tooltip v-if="false">
                <template #title></template>
                <QuestionCircleOutlined/>
              </a-tooltip>
              <span>：</span>
            </span>
          </template>
          <a-input v-model:value="form.eqpname" allow-clear placeholder="请输入设备名称"/>
        </a-form-item>
      </a-col>
      <a-col :span="12">
        <a-form-item name="eqpDesc">
          <template #label>
            <span>
              设备描述
              <a-tooltip v-if="false">
                <template #title></template>
                <QuestionCircleOutlined/>
              </a-tooltip>
              <span>：</span>
            </span>
          </template>
          <a-input v-model:value="form.eqpDesc" allow-clear placeholder="请输入设备描述（简称）"/>
        </a-form-item>
      </a-col>
      <a-col :span="12">
        <a-form-item name="model">
          <template #label>
            <span>
              设备品牌
              <a-tooltip v-if="false">
                <template #title></template>
                <QuestionCircleOutlined/>
              </a-tooltip>
              <span>：</span>
            </span>
          </template>
          <a-input v-model:value="form.model" allow-clear placeholder="请输入设备品牌"/>
        </a-form-item>
      </a-col>
      <a-col :span="12">
        <a-form-item name="type">
          <template #label>
            <span>
              设备型号
              <a-tooltip v-if="false">
                <template #title></template>
                <QuestionCircleOutlined/>
              </a-tooltip>
              <span>：</span>
            </span>
          </template>
          <a-input v-model:value="form.type" allow-clear placeholder="请输入设备型号"/>
        </a-form-item>
      </a-col>
      <a-col :span="12">
        <a-form-item name="eqpClassCode">
          <template #label>
            <span>
              设备类型
              <a-tooltip v-if="false">
                <template #title></template>
                <QuestionCircleOutlined/>
              </a-tooltip>
              <span>：</span>
            </span>
          </template>
          <!--          <dict-select v-model:value="form.eqpClassCode" valueType="dictId" dictTypeId="1348235720908619811" placeholder="请选择" />-->
          <a-select
            v-model:value="form.eqpClassCode"
            placeholder="请选择"
          >
            <a-select-option
              v-for="item in props.eqptypelist"
              :key="item.EQP_CLASS_CODE"
              :value="item.EQP_CLASS_CODE">
              {{ item.EQP_CLASS_NAME }}
            </a-select-option>
          </a-select>
        </a-form-item>
      </a-col>
      <a-col :span="12">
        <a-form-item name="eqpCompany">
          <template #label>
            <span>
              厂商名称
              <a-tooltip v-if="false">
                <template #title></template>
                <QuestionCircleOutlined/>
              </a-tooltip>
              <span>：</span>
            </span>
          </template>
          <a-input v-model:value="form.eqpCompany" allow-clear placeholder="请输入厂商名称"/>
        </a-form-item>
      </a-col>
      <a-col :span="12">
        <a-form-item name="contact">
          <template #label>
            <span>
              联系人
              <a-tooltip v-if="false">
                <template #title></template>
                <QuestionCircleOutlined/>
              </a-tooltip>
              <span>：</span>
            </span>
          </template>
          <a-input v-model:value="form.contact" allow-clear placeholder="请输入联系人"/>
        </a-form-item>
      </a-col>
      <a-col :span="12">
        <a-form-item name="telphone">
          <template #label>
            <span>
              电话
              <a-tooltip v-if="false">
                <template #title></template>
                <QuestionCircleOutlined/>
              </a-tooltip>
              <span>：</span>
            </span>
          </template>
          <a-input v-model:value="form.telphone" allow-clear placeholder="请输入电话"/>
        </a-form-item>
      </a-col>
      <a-col :span="12">
        <a-form-item name="eqpStatus">
          <template #label>
            <span>
              设备状态
              <a-tooltip v-if="false">
                <template #title></template>
                <QuestionCircleOutlined/>
              </a-tooltip>
              <span>：</span>
            </span>
          </template>
          <a-input v-model:value="form.eqpStatus" allow-clear placeholder="请输入设备状态"/>
        </a-form-item>
      </a-col>
      <a-col :span="12">
        <a-form-item name="cncsystem">
          <template #label>
            <span>
              数控系统
              <a-tooltip v-if="false">
                <template #title></template>
                <QuestionCircleOutlined/>
              </a-tooltip>
              <span>：</span>
            </span>
          </template>
          <a-input v-model:value="form.cncsystem" allow-clear placeholder="请输入数控系统"/>
        </a-form-item>
      </a-col>
      <a-col :span="12">
        <a-form-item name="buydate">
          <template #label>
            <span>
              购买日期
              <a-tooltip v-if="false">
                <template #title></template>
                <QuestionCircleOutlined/>
              </a-tooltip>
              <span>：</span>
            </span>
          </template>
          <a-date-picker v-model:value="form.buydate" value-format="YYYYMMDD" placeholder="请选择购买日期"
                         style="width: 100%"/>
        </a-form-item>
      </a-col>
      <a-col :span="12">
        <a-form-item name="eqpNum">
          <template #label>
            <span>
              客户现场设备编码
              <a-tooltip v-if="false">
                <template #title></template>
                <QuestionCircleOutlined/>
              </a-tooltip>
              <span>：</span>
            </span>
          </template>
          <a-input v-model:value="form.eqpNum" allow-clear placeholder="请输入客户现场设备编码"/>
        </a-form-item>
      </a-col>
      <a-col :span="12">
        <a-form-item name="stationCode">
          <template #label>
            <span>
              工位CODE
              <a-tooltip v-if="false">
                <template #title></template>
                <QuestionCircleOutlined/>
              </a-tooltip>
              <span>：</span>
            </span>
          </template>
          <!--          <dict-select v-model:value="form.stationCode" valueType="dictId" dictTypeId="1348235720908619811"
                                 placeholder="请选择"/>-->
          <a-select
            v-model:value="form.stationCode"
            placeholder="请选择"
          >
            <a-select-option
              v-for="item in props.stationlist"
              :key="item.STATION_CODE"
              :value="item.STATION_CODE">
              {{ item.STATION_NAME }}
            </a-select-option>
          </a-select>
        </a-form-item>
      </a-col>
    </a-row>

  </a-form>
</template>

<script setup name="EquipmentForm">
import {reactive} from 'vue';
import {Common} from "@/api/Common";

const props = defineProps({
  // 表单数据
  form: Object,
  isUpdate: false,
  orgidlist: Array,
  eqptypelist: Array,
  stationlist: Array,
});
// 验证规则
const rules = reactive({
  eqpCode: [{required: true, message: '请输入设备CODE', type: 'string', trigger: 'blur'}],
  orgCode: [{required: true, message: '请输入所属组织编码', type: 'string', trigger: 'blur'}],
  eqpClassCode: [{required: true, message: '请输入设备类型', type: 'string', trigger: 'blur'}],
});
defineExpose()

</script>

<style></style>
